package com.kudu.api;

import org.apache.kudu.client.*;

public class selectDemo {
    public static void main(String[] args) {
        KuduClient.KuduClientBuilder builder = new KuduClient.KuduClientBuilder("node51");
        builder.defaultSocketReadTimeoutMs(5000);
        KuduClient client = builder.build();

        try {
            KuduTable stuTable = client.openTable("student");
            KuduScanner scanner = client.newScannerBuilder(stuTable).build();
            while(scanner.hasMoreRows()) {
                for(RowResult result :scanner.nextRows()) {
                    String id = result.getString("id");
                    String name = result.getString("name");
                    int age = result.getInt("age");
                    System.out.println("id:" + id + " \t name:" + name + " \t age:"+age);
                }

            }
        } catch (KuduException e) {
            e.printStackTrace();
        } finally {
            try {
                client.close();
            } catch (KuduException e) {
                e.printStackTrace();
            }
        }


    }
}
